/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.nightknight.satobee.gui;

import java.net.Socket;
import org.nightknight.satobee.core.Contact;
import org.nightknight.satobee.core.Conversation;
import org.nightknight.satobee.core.IMesRecListener;
import org.nightknight.satobee.core.Message;

/**
 *
 * @author nightknight
 */
public class ConversationGUIImpl extends Conversation {
    
    private ConversationView view;
    
    public ConversationGUIImpl(Contact con) {
        super(con);
        
        init();
    }
    
    public ConversationGUIImpl(Socket s) {
        super(s);
        init();
    }
    
    public final void init() {
        view = new ConversationView();
        view.setConversation(this);
        
        this.addMessageReceivedListener(new IMesRecListener() {

            public void messageReceived(Message message) {
                int type = message.getType();
                if (type == 1) {
                    view.addElement(message);
                }
            }
        
        });
    }
    
    public void setVisible(boolean b) {
        view.setVisible(b);
    }
    
    public void fileMesReceived(Message message) {
        view.fileReceived(message);
    }

    @Override
    public void startFileSend() {
        view.addElement(makeMessage(2, "start send"));
//        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void fileSending(int nch) {
//        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void fileSent() {
        view.addElement(makeMessage(2, "file sent"));
//        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void startFileReceive(String str) {
        view.addElement(makeMessage(2, "start receive"));
//        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void fileReceiving(int nch, String str) {
//        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void fileReceived(String str) {
        view.addElement(makeMessage(2, "file received"));
//        throw new UnsupportedOperationException("Not supported yet.");
    }
}
